const path = require('path');

module.exports = {
    entry: './src/index.tsx',
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist'),
    },
    module: { //要打包的第三方模块
        rules: [
            {
                test: /\.less$/,
                use: ['style-loader', "less-loader"],
            },
            { test: /\.css$/, use: 'css-loader' },
            {
                test: /\.(js|jsx|ts|tsx)$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                options: {
                    cacheDirectory: true,
                    cacheCompression: false,
                    plugins: ["@babel/plugin-transform-runtime"]
                }
            },
            {
                test: /\.svg$/,
                use: ['file-loader']
            },
            {
                test: /\.scss$/,
                use: [{
                    loader: "style-loader" // 将 JS 字符串生成为 style 节点
                }, {
                    loader: "css-loader" // 将 CSS 转化成 CommonJS 模块
                }, {
                    loader: "sass-loader" // 将 Sass 编译成 CSS
                }]
            },
        ],
    },

    resolve: {
        extensions: ['*', '.js', '.jsx', '.css', '.less', '.ts', '.tsx', '.scss']
    }
};